package com.hongyan.dao;

import com.hongyan.bean.Class;
import com.hongyan.bean.Homework;
import com.hongyan.bean.Log;
import com.hongyan.util.JDBCUtils;

import java.util.List;

public class LogDao {


    public static Object[][] findlogByName(String name) {

        String sql = "select * from log where l_name like '%" + name + "%' order by l_name asc;";
        List<Log> query = null;
        query = JDBCUtils.query(sql, Log.class);
        Object[][] Log = new Object[query.size()][];
        for (int i = 0; i < query.size(); i++) {
            Log[i] = query.get(i).toArray();
        }
        return Log;

    }


    public static Object[][] getlogListBySql(String sql) {
        List<Log> query = null;
        query = JDBCUtils.query(sql, Log.class);
        Object[][] Log = new Object[query.size()][];
        for (int i = 0; i < query.size(); i++) {
            Log[i] = query.get(i).toArray();
        }
        return Log;

    }

    public static int addLog(Log log) {
        String sql = "insert into log(l_id,l_name,record_time,content) values(?,?,?,?)";
        int update = JDBCUtils.update(sql, log.getL_id(), log.getL_name(), log.getRecord_time(), log.getContent());

        return update;
    }

}

